<div class="border mt-3 p-3">
  <form id="withdraw" class="form form-horizontal" ng-controller="WithdrawsController as withdrawsCtrl" ng-submit="withdrawsCtrl.createWithdraw(currency)">
    <div class="form-group row">
      <div class="col-sm-4">
        <label class="optional control-label">{{"funds.withdraw_coin.balance" | t}}</label>
      </div>
      <div class="col-sm-8">
        <p class="form-control-static"><span class="currency-balance" id="withdraw_balance">{{balance}}</span></p>
      </div>
    </div>

    <div class="form-group row required">
      <div class="col-sm-4">
        <label class="required control-label" for="withdraw_rid">Withdraw address</label>
      </div>
      <div class="col-sm-8">
        <input class="required form-control" id="withdraw_rid" name="withdraw[rid]" placeholder="Recipient wallet address" type="text" ng-model="withdrawsCtrl.withdraw.rid">
      </div>
    </div>

    <div class="form-group row required">
      <div class="col-sm-4">
        <label class="decimal required control-label" for="withdraw_sum">Withdraw amount</label>
      </div>
      <div class="col-sm-8">
        <div class="input-group">
          <input class="numeric decimal required form-control" id="withdraw_sum" name="withdraw[sum]" placeholder="{{'funds.withdraw_coin.min' | t}} 0.001" type="text" value="0.0" ng-model="withdrawsCtrl.withdraw.sum">
          <div class="input-group-btn"><button ng-click="withdrawsCtrl.withdrawAll()" class="btn btn-success" id="withdraw_all_btn" type="button">{{"funds.withdraw_coin.withdraw_all" | t}}</button></div>
        </div>
      </div>
    </div>

    <div class="">
      <div class="form-submit col-sm-18 col-sm-offset-6">
        <input  id="withdraw_submit" class="btn btn-primary" data-loading-text="Creating..." name="commit" type="submit" value="{{'submit' | t}}">
      </div>
    </div>

  </form>
</div>

<h2 class="panel-title mt-5">{{ "funds.withdraw_history.title" | t }}</h2>

<table class="table withdraw-history" ng-controller="WithdrawHistoryController as wdCtrl">
  <tr>
    <th>{{ "funds.withdraw_history.number" | t }}</th>
    <th>{{ "funds.withdraw_history.withdraw_time" | t }}</th>
    <th>{{ "funds.withdraw_history.withdraw_address" | t }}</th>
    <th>{{ "funds.withdraw_history.actual_amount" | t }}</th>
    <th>{{ "funds.withdraw_history.miner_fee" | t }}</th>
    <th>{{ "funds.withdraw_history.state_and_action" | t }}</th>
  </tr>
  <tr ng-repeat="withdraw in wdCtrl.withdraws | orderBy:predicate">
    <td>{{withdraw.id}}</td>
    <td>{{withdraw.created_at | date:'yyyy-MM-dd HH:mm'}}</td>
    <td>
      <a ng-if="withdraw.wallet_url" href="{{withdraw.wallet_url}}" target='_blank'>{{withdraw.rid | truncate: 20}}</a>
      <span ng-if="!withdraw.wallet_url">{{withdraw.rid | truncate: 20}}</span>
    </td>
    <td>{{withdraw.amount}}</td>
    <td>{{withdraw.fee}}</td>
    <td>{{"funds.withdraw_history." + withdraw.aasm_state | t}}
      <span ng-if="wdCtrl.canCancel(withdraw.aasm_state)">/
        <a ng-click="wdCtrl.cancelWithdraw(withdraw); $event.preventDefault()" href="#" class="cancel_link">{{ "funds.withdraw_history.cancel" | t }}</a>
      </span>
    </td>
  </tr>
  <tr ng-if="wdCtrl.noWithdraw()"><td colspan="6"><span class="help-block text-center">{{"funds.withdraw_history.no_data" | t}}</span></td></tr>
</table>


